package com.powernode.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.powernode.dto.NoticeDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.powernode.mapper.NoticeMapper;
import com.powernode.domain.Notice;
import com.powernode.service.impl.NoticeService;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return noticeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Notice record) {
        return noticeMapper.insert(record);
    }

    @Override
    public int insertSelective(Notice record) {
        return noticeMapper.insertSelective(record);
    }

    @Override
    public Notice selectByPrimaryKey(Integer id) {
        return noticeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Notice record) {
        return noticeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Notice record) {
        return noticeMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Notice> queryNoticeForPage(NoticeDto noticeDto) {
        Page<Notice> page = PageHelper.startPage(noticeDto.getPage(), noticeDto.getLimit());
        List<Notice> notices = this.noticeMapper.queryNoticeForPage(noticeDto);
        PageInfo<Notice> info = page.toPageInfo();
        return info;
    }

}
